package estyle.auto.nkornilova.pages;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.FindBy;

import java.util.ArrayList;
import java.util.List;

import static org.openqa.selenium.support.ui.ExpectedConditions.presenceOfElementLocated;

/**
 * Created with IntelliJ IDEA.
 * User: nkornilova
 * Date: 24.04.13
 * Time: 16:47
 * To change this template use File | Settings | File Templates.
 */
public class BankAccountMessageGridPage extends AnyPage {

    public BankAccountMessageGridPage(PageManager pages) {
        super(pages);
    }

    @FindBy(xpath = "//li[@id='15']")
    private WebElement bankAccountDocumentsMenu;

    @FindBy(xpath = "//li[@id='16']")
    private WebElement bankAccountMessageMenu;

    @FindBy(xpath = "//li[@id='13']")
    private WebElement bankAccountMenu;

    @FindBy(id = "content-container")
    private WebElement bankAccountContains;

    public BankAccountMessageGridPage moveToBankAccountMessageGridMenu() {
        new Actions(driver)
                .moveToElement(bankAccountMenu)
                .moveToElement(bankAccountDocumentsMenu)
                .moveToElement(bankAccountMessageMenu).click().perform();
        return this;
    }

    public BankAccountMessageGridPage moveToInnerFrame() {
        moveToFrameByLocator(By.xpath("//iframe[@name='/fbsWeb/baccount/account_message_main.do']"));
        return this;
    }

    //Панель инструментов
    @FindBy(xpath = "//span[@class='l-btn-empty icon-add-o']/../../..")
    private WebElement addCreateMessageButton;

    @FindBy(xpath = "//span[@class='l-btn-empty icon-add-c']/../../..")
    private WebElement addCloseMessageButton;

    @FindBy(xpath = "//span[@class='l-btn-empty icon-add-i']/../../..")
    private WebElement addChangeMessageButton;

    public boolean isVisible()
    {
        //TODO:
         return true;
    }

    //Создать сообщение об открытии
    public MessagePage clickAddCreateMessageButton()
    {
        addCreateMessageButton.click();
        return pages.messagePage;
    }

    //Создать сообщение о закрытии
    public MessagePage clickAddCloseMessageButton()
    {
        addCloseMessageButton.click();
        return pages.messagePage;
    }

    //Создать сообщение об изменении
    public MessagePage clickAddChangeMessageButton()
    {
        addChangeMessageButton.click();
        return pages.messagePage;
    }

}
